package com.spring.gll.dao.impl;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;

import javax.sql.DataSource;

@Transactional
public class SwTest {
    public DataSource dataSource;
    public JdbcTemplate template;

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
        this.template=new JdbcTemplate(dataSource);
    }

    public void swJdbc(){
        String sql1="insert into tb_table values(null,'w')";
//        int i=2/0;
        String sql2="insert into tb_table values(null,'a')";
        template.update(sql1);
        template.update(sql2);
    }
}
